package cn.tedu.mall1.order.service.impl;

import cn.tedu.mall1.order.mapper.OrderMapper;
import cn.tedu.mall1.order.pojo.dto.OrderDTO;
import cn.tedu.mall1.order.pojo.response.PageData;
import cn.tedu.mall1.order.pojo.vo.OrderVO;
import cn.tedu.mall1.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Slf4j
@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;
    @Override
    public PageData select(OrderDTO orderDTO) {
        log.debug("接收到的数据{}",orderDTO);
        OrderDTO dto = new OrderDTO();
        dto.setOrderTime(orderDTO.getOrderTime());
        dto.setFinishTime(orderDTO.getFinishTime());
        BeanUtils.copyProperties(orderDTO,dto);
        List<OrderVO> list = orderMapper.select(dto);
        log.debug("返回查询的结果{}",list);
        PageData orderData = new PageData();
        orderData.setList(list);
        orderData.setTotal(orderMapper.selectNumber(orderDTO));
        return orderData;
    }
}
